package leetcode.editor.cn.q0xx

class Q78MediumSubsets {
    fun subsets(nums: IntArray): List<List<Int>> {
        val ans = ArrayList<List<Int>>()
        val t= ArrayList<Int>()

        val n = nums.size
        for (mask in 0 until (1 shl n)) {
            t.clear()
            for (i in 0 until n) {
                if (mask and (1 shl i) != 0) {
                    t.add(nums[i])
                }
            }
            ans.add(t.toList())
        }
        return ans
    }
}